#include <stdio.h>
#include <stdlib.h>
#include <wait.h>
#include <unistd.h>
#include <sys/resource.h>
const char* command[] = {"/usr/bin/g++", "-O2", "-std=c++11", "-fno-asm", "-fmax-errors=20", "./error1.c", "-o", "./error1.out", NULL};
int main(int argc, char** argv) {
    pid_t pid = fork();
    if (pid == 0) {
        execv("/usr/bin/g++", (char**)command);
    }
    else {
        rusage rusa;
        int status;
        wait4(pid, &status, 0, &rusa);
        if (WIFEXITED(status)) {
            int t = WEXITSTATUS(status);
            printf("exit normally with code: %d\n", t);
        }
        if (WIFSIGNALED(status)) {
            int t = WTERMSIG(status);
            printf("exit with signal code: %d\n", t);
        }
    }
    return 0;
}
